package com.dragon.heap;

import java.util.Random;

/**
 * @author dragon
 * @version V1.0.0-RELEASE
 * @date 2019/5/23 11:06
 */
public class MaxHeapTest {

    public static void main(String[] args) {
        int n = 10000;
        MaxHeap<Integer> maxHeap = new MaxHeap<>();
        Random random = new Random();
        for (int i = 0; i < n; i++) {
            maxHeap.add(random.nextInt(Integer.MAX_VALUE));
        }
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = maxHeap.extractMax();
            System.out.print(arr[i] + " ");
        }

        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > arr[i - 1]) {
                throw new RuntimeException("error");
            }
        }
    }
}
